package com.xwt.web.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.xwt.web.dao.AuthorityRepository;
import com.xwt.web.dao.UserRepository;
import com.xwt.web.entity.Authority;
import com.xwt.web.entity.User;

@RestController
@RequestMapping("/user")
public class UserController {
	@Autowired
	private UserRepository userRepository;
	@Autowired
	private AuthorityRepository authorityRepository;

	@RequestMapping("/userinfo")
	public User getUserInfo(@RequestParam(value = "username", required = true) String username) {
		User user = userRepository.findByUsername(username);
		return user;

	}

	@RequestMapping("/authority")
	public List<Authority> getAuthoritys(@RequestParam String username) {
		List<Authority> list = authorityRepository.findByUsername(username);
		return list;
	}
}
